<template>
  <div class="header">
    <!--顶部内容-->
    <div class="content-wrapper">
      <!--左侧图片区域-->
      <div class="avatar">
        <img width='64' height='64' :src='this.seller.avatar'>
      </div>
      <!--右侧-->
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class='name'>{{this.seller.name}}</span>
        </div>
        <!--描述-->
        <div class="description">
          {{this.seller.description}}/{{this.seller.deliveryTime}}分钟送达
        </div>
        <div class="support"  v-if='this.seller.supports'>
          <span class="icon" :class='classes'></span>
          <span class="text">{{this.seller.supports[0].description}}</span>
        </div>
      </div>
      <!--右侧优惠数量-->
      <div class="support-count" v-if="this.seller.supports"  @click="showDetail">
        <span class="count">{{this.seller.supports.length}}个</span>
        <span class='iconfont'>&#xe603;</span>
      </div>
    </div>
    <!--下面公告-->
    <div class="bulletin-wrapper" @click="showDetail">
      <div class="bulletin-title"></div>
      <div class="bulletin-info">
        <div class="bulletin-text">{{this.seller.bulletin}}</div>
      </div>
      <span class='iconfont'>&#xe603;</span>
    </div>
    <!--背景-->
    <div class="background">
      <img :src="this.seller.avatar" width="100%" height="100%">
    </div>
    <!--浮层-->
    <!--sticky footer布局------------------------------------>
    <div class="detail" v-show="detailShow">
      <!--内容层包裹---------clearfix用来清除浮动-->
      <div class="detail-wrapper clearfix">
        <!--真正的内容层-->
        <div class="detail-main">
          <h1 class="name">{{this.seller.name}}</h1>
          <!--评星区块-->
          <div class='star-wrapper'> 
            <star :size='48' :score='this.seller.score'></star>
          </div>
          <!--分隔区块-->
          <div class="title">
            <div class="line"></div>
            <div class='text'>优惠信息</div>
            <div class="line"></div>
          </div>
          <!--优惠列表-->
          <!--折扣区-->
          <ul v-if="this.seller.supports" class="supports">
            <li class="support-item" v-for="(item,index) in seller.supports" :key='index'>
              <span class="icon" :class="classMap[item.type]"></span>
              <span class="text">{{item.description}}</span>
            </li>
          </ul>
          <!--分隔区块-->
          <div class="title">
            <div class="line"></div>
            <div class='text'>商家公告</div>
            <div class="line"></div>
          </div>
          <!--公告信息-->
          <div class="bulletin">
            <p class="content">{{this.seller.bulletin}}</p>
          </div>
        </div>
      </div>
      <!--底部关闭浮层-->
      <div class="detail-close" @click="hideDetail">
        <span class='iconfont'>&#xe608;</span>
      </div>
    </div>
    <!--sticky footer布局------------------------------------>
  </div>
</template>

<script>
import star from '../star/star'
export default {
  name:'home',
  props:{
    seller:Object
  },
  components:{
    star
  },
  data(){
    return{
     detailShow:false
    }
  },
  created(){
    this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee'];
  },
  methods:{
    showDetail() {
      this.detailShow = true;
    },
    hideDetail() {
      this.detailShow = false;
    }
  },
  computed:{
    //特惠添加背景图片，根据不同的index添加不同的小图标
    classes(){
       const index=this.seller.supports[0].type
       return this.classMap[index]
    }
  }
}

</script>

<style lang="stylus" scoped>
 @import "../../commen/stylus/mixin.styl";
.header 
  overflow:hidden//解决blur透出阴影
  color:#fff 
  position:relative
  background: rgba(7, 17, 27, .5)//半透明透到这个图片
  .content-wrapper 
    position:relative
    display:flex
    padding:24px 12px 18px 24px
    .avatar 
      img
        border-radius: 2px
    .content
      flex:1
      margin-left:16px
      font-size:14px 
      .title
        margin:2px 0 8px 0
        font-size:18px
        .brand
          display:inline-block
          vertical-align:top
          width:30px 
          height:18px
          background-size: 30px 18px
          background-repeat:no-repeat
          bg-image('brand')
        .name
          margin-left:6px;
          font-size:16px;
          line-height:18px;
      .description
        margin-bottom: 10px
        line-height: 12px
        font-size: 12px
      .support
        .icon
          display: inline-block
          vertical-align:bottom
          text-align:center
          width: 12px
          height: 12px
          margin-right: 4px
          background-size: 12px 12px
          background-repeat: no-repeat
          &.decrease
            bg-image('decrease_1')
          &.discount
            bg-image('discount_1')
          &.guarantee
            bg-image('guarantee_1')
          &.invoice
            bg-image('invoice_1')
          &.special
            bg-image('special_1')
          .text
            line-height:12px
            font-size:10px
    .support-count
      position:absolute
      background-color:rgba(230,230,230,.2)
      right:12px 
      bottom:18px 
      padding:0 8px
      height:24px 
      line-height:24px
      border-radius:14px
      font-size:10px
      .count
        vertical-align:top
      .iconfont
        height:24px 
        line-height:24px
        font-size:10px
  .bulletin-wrapper
    display:flex
    justify-content:center
    align-items:center
    position:relative
    height: 28px
    line-height: 28px
    background:red
    padding: 0 22px 0 12px
    background: rgba(7, 17, 27, 0.2)
    .bulletin-title
      width:22px
      height:12px
      bg-image('bulletin')
      background-size:22px 
      background-repeat:no-repeat
    .bulletin-info
      //position:relative
      flex:1
      min-width:0
      .bulletin-text
        margin: 0 4px
        font-size: 10px
        white-space: nowrap
        overflow: hidden
        text-overflow: ellipsis
    .iconfont
      position: absolute
      font-size: 10px
      right: 8px
      top: 3px
  .background
    position: absolute
    top: 0
    left: 0
    width: 100%
    height: 100%
    z-index: -1
    filter: blur(10px)
  .detail
    position:fixed 
    top:0
    left:0
    width:100%
    height:100%
    z-index:100 
    overflow:auto //根据内容现实滚动条与否
    background-color:rgba(7,17,27,.8)
    .detail-wrapper
      min-height: 100%
      width: 100%
      .detail-main
        margin-top: 64px
        padding-bottom: 64px//必须要有，是x关闭按钮所占高度
        .name
          line-height: 16px
          text-align: center
          font-size: 16px
          font-weight: 700
        .star-wrapper
          margin-top: 18px
          padding: 2px 0
          text-align: center
        .title
          display:flex
          width:80%
          margin:30px auto 24px
          .line
            flex:1
            position: relative
            top: -6px
            border-bottom: 1px solid rgba(255, 255, 255, 0.2)
          .text
            padding: 0 12px
            font-weight: 700
            font-size: 14px
        .supports
          width: 80%
          margin: 0 auto
          .support-item
            padding: 0 12px
            margin-bottom: 12px
            font-size: 0
            &:last-child
              margin-bottom: 0
            .icon
              display: inline-block
              width: 16px
              height: 16px
              vertical-align: top
              margin-right: 6px
              background-size: 16px 16px
              background-repeat: no-repeat
              &.decrease
                bg-image('decrease_2')
              &.discount
                bg-image('discount_2')
              &.guarantee
                bg-image('guarantee_2')
              &.invoice
                bg-image('invoice_2')
              &.special
                bg-image('special_2')
            .text
              line-height: 16px
              font-size: 12px
        .bulletin
          width: 80%//自适应居中
          margin: 0 auto
          .content
            line-height: 24px
            padding: 0 12px//填充内边距
            font-size:12px
    .detail-close
      position:relative
      width:32px 
      margin:-64px auto 0
      //clear: both
      font-size: 32px
</style>